function playVideo(videoUrl) {
    const videoPlayer = document.getElementById('videoPlayer');
    videoPlayer.src = videoUrl;
    const videoModal = new bootstrap.Modal(document.getElementById('videoModal'));
    videoModal.show();
}

// 当模态框关闭时停止视频播放
document.getElementById('videoModal').addEventListener('hidden.bs.modal', function () {
    document.getElementById('videoPlayer').pause();
});

function deleteVideo(videoId) {
    if (confirm('确定要删除这个视频吗？')) {
        fetch(`/video/${videoId}`, {
            method: 'DELETE',
        })
        .then(response => response.json())
        .then(data => {
            if (data.success) {
                location.reload();
            } else {
                alert('删除失败：' + data.error);
            }
        })
        .catch(error => {
            console.error('Error:', error);
            alert('删除失败');
        });
    }
}